/**
 * @typedef UserBody
 * @property {string} id.required
 * @property {string} nickname
 * @property {string} gender
 * @property {string} avatar
 * @property {integer} age
 * @property {string} job
 * @property {string} description
 */

const express = require('express')
const router = express.Router()
const auth = require('@/middleware/auth.middleware')
const userController = require('@/controllers/user.controller')

/**
 * 用户列表分页查询
 * @route GET /user
 * @summary 用户列表分页查询
 * @group 用户管理
 * @param {string} pageNo.query.required
 * @param {string} pageSize.query.required
 * @param {string} searchKeywords.query
 * @param {string} status.query
 * @param {string} username.query
 * @param {string} nickname.query
 * @param {string} email.query
 * @param {string} tel.query
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access user-list-manage-permission:btn:find
 * @security JWT
 */
router.get('/', auth(), userController.findPage)

/**
 * 更新用户状态
 * @route PUT /user/updateStatus
 * @summary 更新用户状态
 * @group 用户管理
 * @param {string} id.query.required
 * @param {string} status.query.required
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access user-list-manage-permission:btn:edit
 * @security JWT
 */
router.put('/updateStatus', auth(), userController.updateStatus)

/**
 * 更新用户基本信息
 * @route PUT /user
 * @summary 更新用户基本信息
 * @group 用户管理
 * @param {UserBody.model} UserBody.body.required
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access user-list-manage-permission:btn:edit
 * @security JWT
 */
router.put('/', auth(), userController.update)

module.exports = router
